home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.centrum.is!news
- From: bjarnir@centrum.is (Bjarni Ragnarsson)
- Newsgroups: comp.lang.c++
- Subject: Re: Array declaration
- Date: 11 Apr 1996 15:08:55 GMT
- Organization: BR Software
- Message-ID: <4kj7a7$m72@newshost.centrum.is>
- References: <4jvo2g$mp2@hermes.is.co.za>
- NNTP-Posting-Host: tungl-54.centrum.is
- X-Newsreader: WinVN version 0.82
-
- In article <4jvo2g$mp2@hermes.is.co.za>, janinep@geoscience.org.za (Janine Prinsloo) says:
- >
- >I declared the following array: dat[7][2048]
- >In the program I made the stupid mistake of using loops going from 1 to 7
- >and from 1 to 2048 instead of 0 to 6 and 0 to 2047. What I don't understand
- >is that the program ran fine for a number of times (the program is repeatedly
- >run by a batch program) before an error occurred.
- >
- >I would like to know why an error didn't occur immediately the first time
- >the program was run.
- >
- >Janine
- >
- >(I used Borland C++ v4.0 to compile the program)
-
- What sort of error did it give....Out of range or something like that ?
-
- I don't believe any range checking is done. Your range (7x2048) instructs the
- compiler to reserve memory of that size for your array.
- If you go outside the predefined range, that is your problem. If you write outside
- the predefined range, you are however (probably) poking into "someone" else's
- address with unpredictible results. Sometimes it doesn't matter and sometimes
- it does.
-
- Bjarni Ragnarsson
- bjarnir@centrum.is
-